"""
给定数组A，以及[L,R]，找一个长度在之间且和大于零的最小和。
注意到规模很小，直接暴力
"""
class Solution:
    def minimumSumSubarray(self, nums: List[int], l: int, r: int) -> int:
        n = len(nums)
        s = [0 for i in range(n + 1)]
        for i in range(n):
            s[i + 1] = s[i] + nums[i]
        ans = -1
        for i in range(l, r + 1):
            tmp = self.f(i, nums)
            if -1 != tmp:
                if -1 == ans or ans > tmp:
                    ans = tmp
        return ans

    def f(self, n, nums):
        N = len(nums)
        ret = -1
        for i in range(N - n + 1):
            tmp = sum(nums[i:i+n])
            if tmp > 0:
                if -1 == ret or ret > tmp:
                    ret = tmp
        return ret